﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace MvcHeatloss.Models
{
    public partial class Ceiling
    {
        public ProjectEntities db = new ProjectEntities();
        
        public Ceiling(double length, double width, string type, int temp)
        {
            CeilingArea = length * width;
            CeilingType = type;
            CeilingUValue = (double)db.UValues.Where(d => d.Description == type).Select(u => u.UValue1).First();
            CeilingTemp = temp;
            CeilingHeatloss = CalcHeatoss.FabricHeatloss(this.CeilingUValue, this.CeilingArea, this.CeilingTemp);

        }
        public Ceiling()
        {
        }

        public string CeilingType { get; set; }
        
        public int CeilingTemp { get; set; }
        
        public double CeilingUValue { get; set; }

        public double CeilingArea { get; set; }

        double ceilingHeatloss;
        public double CeilingHeatloss
        {
            get
            {
                return ceilingHeatloss;
            }
            set
            {
                ceilingHeatloss = CalcHeatoss.FabricHeatloss(this.CeilingUValue, this.CeilingArea, this.CeilingTemp);
            }
        }
    }
}